
/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2022原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;

/**
 * Indicates that a class declares one or more {@link Bean @Bean} methods and
 * may be processed by the Spring container to generate bean definitions and
 * service requests for those beans at runtime, for example:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class AppConfig {
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         // instantiate, configure and return bean ...
 *     }
 * }</pre>
 *
 * <h2>Bootstrapping {@code @Configuration} classes</h2>
 *
 * <h3>Via {@code AnnotationConfigApplicationContext}</h3>
 *
 * <p>{@code @Configuration} classes are typically bootstrapped using either
 * {@link AnnotationConfigApplicationContext} or its web-capable variant,
 * {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
 * AnnotationConfigWebApplicationContext}. A simple example with the former follows:
 *
 * <pre class="code">
 * AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
 * ctx.register(AppConfig.class);
 * ctx.refresh();
 * MyBean myBean = ctx.getBean(MyBean.class);
 * // use myBean ...
 * </pre>
 *
 * <p>See the {@link AnnotationConfigApplicationContext} javadocs for further details, and see
 * {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
 * AnnotationConfigWebApplicationContext} for web configuration instructions in a
 * {@code Servlet} container.
 *
 * <h3>Via Spring {@code <beans>} XML</h3>
 *
 * <p>As an alternative to registering {@code @Configuration} classes directly against an
 * {@code AnnotationConfigApplicationContext}, {@code @Configuration} classes may be
 * declared as normal {@code <bean>} definitions within Spring XML files:
 *
 * <pre class="code">
 * &lt;beans&gt;
 *    &lt;context:annotation-config/&gt;
 *    &lt;bean class="com.acme.AppConfig"/&gt;
 * &lt;/beans&gt;
 * </pre>
 *
 * <p>In the example above, {@code <context:annotation-config/>} is required in order to
 * enable {@link ConfigurationClassPostProcessor} and other annotation-related
 * post processors that facilitate handling {@code @Configuration} classes.
 *
 * <h3>Via component scanning</h3>
 *
 * <p>{@code @Configuration} is meta-annotated with {@link Component @Component}, therefore
 * {@code @Configuration} classes are candidates for component scanning (typically using
 * Spring XML's {@code <context:component-scan/>} element) and therefore may also take
 * advantage of {@link Autowired @Autowired}/{@link jakarta.inject.Inject @Inject}
 * like any regular {@code @Component}. In particular, if a single constructor is present
 * autowiring semantics will be applied transparently for that constructor:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class AppConfig {
 *
 *     private final SomeBean someBean;
 *
 *     public AppConfig(SomeBean someBean) {
 *         this.someBean = someBean;
 *     }
 *
 *     // &#064;Bean definition using "SomeBean"
 *
 * }</pre>
 *
 * <p>{@code @Configuration} classes may not only be bootstrapped using
 * component scanning, but may also themselves <em>configure</em> component scanning using
 * the {@link ComponentScan @ComponentScan} annotation:
 *
 * <pre class="code">
 * &#064;Configuration
 * &#064;ComponentScan("com.acme.app.services")
 * public class AppConfig {
 *     // various &#064;Bean definitions ...
 * }</pre>
 *
 * <p>See the {@link ComponentScan @ComponentScan} javadocs for details.
 *
 * <h2>Working with externalized values</h2>
 *
 * <h3>Using the {@code Environment} API</h3>
 *
 * <p>Externalized values may be looked up by injecting the Spring
 * {@link org.springframework.core.env.Environment} into a {@code @Configuration}
 * class &mdash; for example, using the {@code @Autowired} annotation:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class AppConfig {
 *
 *     &#064;Autowired Environment env;
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         MyBean myBean = new MyBean();
 *         myBean.setName(env.getProperty("bean.name"));
 *         return myBean;
 *     }
 * }</pre>
 *
 * <p>Properties resolved through the {@code Environment} reside in one or more "property
 * source" objects, and {@code @Configuration} classes may contribute property sources to
 * the {@code Environment} object using the {@link PropertySource @PropertySource}
 * annotation:
 *
 * <pre class="code">
 * &#064;Configuration
 * &#064;PropertySource("classpath:/com/acme/app.properties")
 * public class AppConfig {
 *
 *     &#064;Inject Environment env;
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         return new MyBean(env.getProperty("bean.name"));
 *     }
 * }</pre>
 *
 * <p>See the {@link org.springframework.core.env.Environment Environment}
 * and {@link PropertySource @PropertySource} javadocs for further details.
 *
 * <h3>Using the {@code @Value} annotation</h3>
 *
 * <p>Externalized values may be injected into {@code @Configuration} classes using
 * the {@link Value @Value} annotation:
 *
 * <pre class="code">
 * &#064;Configuration
 * &#064;PropertySource("classpath:/com/acme/app.properties")
 * public class AppConfig {
 *
 *     &#064;Value("${bean.name}") String beanName;
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         return new MyBean(beanName);
 *     }
 * }</pre>
 *
 * <p>This approach is often used in conjunction with Spring's
 * {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
 * PropertySourcesPlaceholderConfigurer} that can be enabled <em>automatically</em>
 * in XML configuration via {@code <context:property-placeholder/>} or <em>explicitly</em>
 * in a {@code @Configuration} class via a dedicated {@code static} {@code @Bean} method
 * (see "a note on BeanFactoryPostProcessor-returning {@code @Bean} methods" of
 * {@link Bean @Bean}'s javadocs for details). Note, however, that explicit registration
 * of a {@code PropertySourcesPlaceholderConfigurer} via a {@code static} {@code @Bean}
 * method is typically only required if you need to customize configuration such as the
 * placeholder syntax, etc. Specifically, if no bean post-processor (such as a
 * {@code PropertySourcesPlaceholderConfigurer}) has registered an <em>embedded value
 * resolver</em> for the {@code ApplicationContext}, Spring will register a default
 * <em>embedded value resolver</em> which resolves placeholders against property sources
 * registered in the {@code Environment}. See the section below on composing
 * {@code @Configuration} classes with Spring XML using {@code @ImportResource}; see
 * the {@link Value @Value} javadocs; and see the {@link Bean @Bean} javadocs for details
 * on working with {@code BeanFactoryPostProcessor} types such as
 * {@code PropertySourcesPlaceholderConfigurer}.
 *
 * <h2>Composing {@code @Configuration} classes</h2>
 *
 * <h3>With the {@code @Import} annotation</h3>
 *
 * <p>{@code @Configuration} classes may be composed using the {@link Import @Import} annotation,
 * similar to the way that {@code <import>} works in Spring XML. Because
 * {@code @Configuration} objects are managed as Spring beans within the container,
 * imported configurations may be injected &mdash; for example, via constructor injection:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class DatabaseConfig {
 *
 *     &#064;Bean
 *     public DataSource dataSource() {
 *         // instantiate, configure and return DataSource
 *     }
 * }
 *
 * &#064;Configuration
 * &#064;Import(DatabaseConfig.class)
 * public class AppConfig {
 *
 *     private final DatabaseConfig dataConfig;
 *
 *     public AppConfig(DatabaseConfig dataConfig) {
 *         this.dataConfig = dataConfig;
 *     }
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         // reference the dataSource() bean method
 *         return new MyBean(dataConfig.dataSource());
 *     }
 * }</pre>
 *
 * <p>Now both {@code AppConfig} and the imported {@code DatabaseConfig} can be bootstrapped
 * by registering only {@code AppConfig} against the Spring context:
 *
 * <pre class="code">
 * new AnnotationConfigApplicationContext(AppConfig.class);</pre>
 *
 * <h3>With the {@code @Profile} annotation</h3>
 *
 * <p>{@code @Configuration} classes may be marked with the {@link Profile @Profile} annotation to
 * indicate they should be processed only if a given profile or profiles are <em>active</em>:
 *
 * <pre class="code">
 * &#064;Profile("development")
 * &#064;Configuration
 * public class EmbeddedDatabaseConfig {
 *
 *     &#064;Bean
 *     public DataSource dataSource() {
 *         // instantiate, configure and return embedded DataSource
 *     }
 * }
 *
 * &#064;Profile("production")
 * &#064;Configuration
 * public class ProductionDatabaseConfig {
 *
 *     &#064;Bean
 *     public DataSource dataSource() {
 *         // instantiate, configure and return production DataSource
 *     }
 * }</pre>
 *
 * <p>Alternatively, you may also declare profile conditions at the {@code @Bean} method level
 * &mdash; for example, for alternative bean variants within the same configuration class:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class ProfileDatabaseConfig {
 *
 *     &#064;Bean("dataSource")
 *     &#064;Profile("development")
 *     public DataSource embeddedDatabase() { ... }
 *
 *     &#064;Bean("dataSource")
 *     &#064;Profile("production")
 *     public DataSource productionDatabase() { ... }
 * }</pre>
 *
 * <p>See the {@link Profile @Profile} and {@link org.springframework.core.env.Environment}
 * javadocs for further details.
 *
 * <h3>With Spring XML using the {@code @ImportResource} annotation</h3>
 *
 * <p>As mentioned above, {@code @Configuration} classes may be declared as regular Spring
 * {@code <bean>} definitions within Spring XML files. It is also possible to
 * import Spring XML configuration files into {@code @Configuration} classes using
 * the {@link ImportResource @ImportResource} annotation. Bean definitions imported from
 * XML can be injected &mdash; for example, using the {@code @Inject} annotation:
 *
 * <pre class="code">
 * &#064;Configuration
 * &#064;ImportResource("classpath:/com/acme/database-config.xml")
 * public class AppConfig {
 *
 *     &#064;Inject DataSource dataSource; // from XML
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         // inject the XML-defined dataSource bean
 *         return new MyBean(this.dataSource);
 *     }
 * }</pre>
 *
 * <h3>With nested {@code @Configuration} classes</h3>
 *
 * <p>{@code @Configuration} classes may be nested within one another as follows:
 *
 * <pre class="code">
 * &#064;Configuration
 * public class AppConfig {
 *
 *     &#064;Inject DataSource dataSource;
 *
 *     &#064;Bean
 *     public MyBean myBean() {
 *         return new MyBean(dataSource);
 *     }
 *
 *     &#064;Configuration
 *     static class DatabaseConfig {
 *         &#064;Bean
 *         DataSource dataSource() {
 *             return new EmbeddedDatabaseBuilder().build();
 *         }
 *     }
 * }</pre>
 *
 * <p>When bootstrapping such an arrangement, only {@code AppConfig} need be registered
 * against the application context. By virtue of being a nested {@code @Configuration}
 * class, {@code DatabaseConfig} <em>will be registered automatically</em>. This avoids
 * the need to use an {@code @Import} annotation when the relationship between
 * {@code AppConfig} and {@code DatabaseConfig} is already implicitly clear.
 *
 * <p>Note also that nested {@code @Configuration} classes can be used to good effect
 * with the {@code @Profile} annotation to provide two options of the same bean to the
 * enclosing {@code @Configuration} class.
 *
 * <h2>Configuring lazy initialization</h2>
 *
 * <p>By default, {@code @Bean} methods will be <em>eagerly instantiated</em> at container
 * bootstrap time.  To avoid this, {@code @Configuration} may be used in conjunction with
 * the {@link Lazy @Lazy} annotation to indicate that all {@code @Bean} methods declared
 * within the class are by default lazily initialized. Note that {@code @Lazy} may be used
 * on individual {@code @Bean} methods as well.
 *
 * <h2>Testing support for {@code @Configuration} classes</h2>
 *
 * <p>The Spring <em>TestContext framework</em> available in the {@code spring-test} module
 * provides the {@code @ContextConfiguration} annotation which can accept an array of
 * <em>component class</em> references &mdash; typically {@code @Configuration} or
 * {@code @Component} classes.
 *
 * <pre class="code">
 * &#064;ExtendWith(SpringExtension.class)
 * &#064;ContextConfiguration(classes = {AppConfig.class, DatabaseConfig.class})
 * class MyTests {
 *
 *     &#064;Autowired MyBean myBean;
 *
 *     &#064;Autowired DataSource dataSource;
 *
 *     &#064;Test
 *     void test() {
 *         // assertions against myBean ...
 *     }
 * }</pre>
 *
 * <p>See the
 * <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#testcontext-framework">TestContext framework</a>
 * reference documentation for details.
 *
 * <h2>Enabling built-in Spring features using {@code @Enable} annotations</h2>
 *
 * <p>Spring features such as asynchronous method execution, scheduled task execution,
 * annotation driven transaction management, and even Spring MVC can be enabled and
 * configured from {@code @Configuration} classes using their respective "{@code @Enable}"
 * annotations. See
 * {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync},
 * {@link org.springframework.scheduling.annotation.EnableScheduling @EnableScheduling},
 * {@link org.springframework.transaction.annotation.EnableTransactionManagement @EnableTransactionManagement},
 * {@link org.springframework.context.annotation.EnableAspectJAutoProxy @EnableAspectJAutoProxy},
 * and {@link org.springframework.web.servlet.config.annotation.EnableWebMvc @EnableWebMvc}
 * for details.
 *
 * <h2>Constraints when authoring {@code @Configuration} classes</h2>
 *
 * <ul>
 * <li>Configuration classes must be provided as classes (i.e. not as instances returned
 * from factory methods), allowing for runtime enhancements through a generated subclass.
 * <li>Configuration classes must be non-final (allowing for subclasses at runtime),
 * unless the {@link #proxyBeanMethods() proxyBeanMethods} flag is set to {@code false}
 * in which case no runtime-generated subclass is necessary.
 * <li>Configuration classes must be non-local (i.e. may not be declared within a method).
 * <li>Any nested configuration classes must be declared as {@code static}.
 * <li>{@code @Bean} methods may not in turn create further configuration classes
 * (any such instances will be treated as regular beans, with their configuration
 * annotations remaining undetected).
 * </ul>
 *
 * @author Rod Johnson
 * @author Chris Beams
 * @author Juergen Hoeller
 * @since 3.0
 * @see Bean
 * @see Profile
 * @see Import
 * @see ImportResource
 * @see ComponentScan
 * @see Lazy
 * @see PropertySource
 * @see AnnotationConfigApplicationContext
 * @see ConfigurationClassPostProcessor
 * @see org.springframework.core.env.Environment
 * @see org.springframework.test.context.ContextConfiguration
 */
/**
 *指示一个类声明一个或多个{@link-Bean@Bean}方法，并且
 *可以由Spring容器处理以生成bean定义，并且
 *运行时对这些bean的服务请求，例如：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类AppConfig{
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *//实例化、配置并返回bean。。。
 *     }
 *}</pre>
 *
 *＜h2＞引导｛@code@Configuration｝类</h2>
 *
 *<h3>通过｛@code AnnotationConfigApplicationContext｝</h3>
 *
 *＜p＞｛@code@Configuration｝类通常使用
 *{@link AnnotationConfigApplicationContext}或其具有网络功能的变体，
 *｛@link org.springframework.web.context.support.AnnationConfigWebApplicationContext
 *AnnotationConfigWebApplicationContext｝。前者的一个简单示例如下：
 *
 *<pre-class=“code”>
 *AnnotationConfigApplicationContext ctx=新的AnnotationConfigurationApplicationContext（）；
 *ctx.register（AppConfig.class）；
 *ctx.refresh（）；
 *MyBean MyBean=ctx.getBean（MyBean.class）；
 *//使用myBean。。。
 *</pre>
 *
 *＜p＞有关更多详细信息，请参阅｛@link AnnotationConfigApplicationContext｝javadocs，并参阅
 *｛@link org.springframework.web.context.support.AnnationConfigWebApplicationContext
 *AnnotationConfigWebApplicationContext｝中的web配置说明
 *｛@code Servlet｝容器。
 *
 *＜h3＞通过Spring｛@code＜beans＞｝XML</h3>
 *
 *<p>作为直接针对
 *｛@code AnnotationConfigApplicationContext｝，｛@code@Configuration｝类可以是
 *在Spring XML文件中声明为正常的{@code＜bean＞}定义：
 *
 *<pre-class=“code”>
 *&lt；豆类&gt；
 *&lt；上下文：注释配置/&gt；
 *&lt；bean class=“com.acme.AppConfig”/&gt；
 *&lt/豆类&gt；
 *</pre>
 *
 *＜p＞在上面的例子中，需要｛@code＜context:annotation config/＞｝
 *启用｛@link ConfigurationClassPostProcessor｝和其他与注释相关的
 *便于处理｛@code@Configuration｝类的后处理器。
 *
 *<h3>通过组件扫描</h3>
 *
 *＜p＞｛@code@Configuration｝是用｛@link Component@Component｝进行元注释的，因此
 *｛@code@Configuration｝类是组件扫描的候选类（通常使用
 *Spring XML的｛@code＜context:component scan/＞｝元素），因此也可能
 *{@link Autowired@Autowired}/{@link jakarta.inject.inject@inject}的优点
 *就像任何常规的{@code@Component}一样。特别是，如果存在单个构造函数
 *自动布线语义将透明地应用于该构造函数：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类AppConfig{
 *
 *私人决赛SomeBean SomeBean；
 *
 *公共应用程序配置（SomeBean SomeBean）{
 *this.someBean=someBean；
 *     }
 *
 *     // &#064;使用“SomeBean”定义Bean
 *
 *}</pre>
 *
 *＜p＞｛@code@Configuration｝类不仅可以使用
 *组件扫描，但也可以自己<em>使用配置</em>组件扫描
 *｛@link ComponentScan@ComponentScan｝注释：
 *
 *<pre-class=“code”>
 * &#064;配置
 * &#064;组件扫描（“com.acme.app.services”）
 *公共类AppConfig{
 *//各种&#064；Bean定义。。。
 *}</pre>
 *
 *<p>有关详细信息，请参阅{@link ComponentScan@ComponentScan}javadocs。
 *
 *<h2>使用外部化的值</h2>
 *
 *<h3>使用｛@code Environment｝API</h3>
 *
 *<p>可以通过注入Spring来查找外部化值
 *｛@link org.springframework.core.env.env.env｝转换为｛@code@Configuration｝
 *阶级&mdash；例如，使用{@code@Autowired}注释：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类AppConfig{
 *
 *     &#064;自动布线环境env；
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *MyBean MyBean=新的MyBean（）；
 *myBean.setName（env.getProperty（“bean.name”））；
 *返回myBean；
 *     }
 *}</pre>
 *
 *<p>通过{@code Environment}解析的财产驻留在一个或多个“属性”中
 *source”对象，并且｛@code@Configuration｝类可能会将属性源贡献给
 *使用｛@link PropertySource@PropertySource｝的｛@code Environment｝对象
 *注释：
 *
 *<pre-class=“code”>
 * &#064;配置
 * &#064;PropertySource（“classpath:/com/acme/app.properties”）
 *公共类AppConfig{
 *
 *     &#064;注入环境env；
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *返回新的MyBean（env.getProperty（“bean.name”））；
 *     }
 *}</pre>
 *
 *<p>请参阅｛@link org.springframework.core.env.env.Environment Environment｝
 *和{@linkPropertySource@PropertySource}javadocs获取更多详细信息。
 *
 *<h3>使用｛@code@Value｝注释</h3>
 *
 *＜p＞可以使用将外部化的值注入｛@code@Configuration｝类
 *｛@link Value@Value｝注释：
 *
 *<pre-class=“code”>
 * &#064;配置
 * &#064;PropertySource（“classpath:/com/acme/app.properties”）
 *公共类AppConfig{
 *
 *     &#064;值（“$｛bean.name｝”）字符串beanName；
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *返回新的MyBean（beanName）；
 *     }
 *}</pre>
 *
 *<p>此方法经常与Spring的
 *｛@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
 *PropertySourcesPlaceholderConfigurer｝，可以自动启用<em></em>
 *在XML配置中通过｛@code＜context:属性占位符/＞｝或＜em＞显式</em>
 *在｛@code@Configuration｝类中，通过专用的｛@code static｝｛@code@Bean｝方法
 *（请参阅的“关于BeanFactoryPostProcessor返回｛@code@Bean｝方法的说明”
 *｛@link-Bean@Bean｝的javadocs获取详细信息）。然而，请注意，明确的注册
 *通过｛@code static｝｛@code@Bean｝
 *方法通常仅在需要自定义配置（如
 *占位符语法等。特别是，如果没有bean后处理器（例如
 *｛@code PropertySourcesPlaceholderConfigurer｝）注册了一个＜em＞嵌入值
 *解析器</em>对于{@code ApplicationContext}，Spring将注册一个默认的
 *<em>嵌入式值解析程序</em>，它根据属性源解析占位符
 *已在｛@code Environment｝中注册。请参阅下面关于作曲的部分
 *｛@code@Configuration｝类使用｛@code@ImportResource｝；看见
 *{@link-Value@Value}的javadocs；有关详细信息，请参阅{@link-Bean@Bean}javadocs
 *关于使用{@code BeanFactoryPostProcessor}类型，例如
 *｛@code PropertySourcesPlaceholderConfigurer｝。
 *
 *＜h2＞编写｛@code@Configuration｝类</h2>
 *
 *<h3>带有｛@code@Import｝注释</h3>
 *
 *＜p＞｛@code@Configuration｝类可以使用｛@link Import@Import｝注释组成，
 *类似于{@code＜import＞}在Spring XML中的工作方式。因为
 *{@code@Configuration}对象作为容器中的Spring bean进行管理，
 *可以注入导入的配置&mdash；例如，通过构造函数注入：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类DatabaseConfig{
 *
 *     &#064;豆
 *公共数据源DataSource（）{
 *//实例化、配置并返回DataSource
 *     }
 * }
 *
 * &#064;配置
 * &#064;导入（DatabaseConfig.class）
 *公共类AppConfig{
 *
 *私有最终数据库配置数据配置；
 *
 *公共AppConfig（数据库配置数据配置）{
 *this.dataConfig=数据配置；
 *     }
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *//引用dataSource（）bean方法
 *返回新的MyBean（dataConfig.dataSource（））；
 *     }
 *}</pre>
 *
 *＜p＞现在，{@code AppConfig｝和导入的{@code DatabaseConfig｝都可以启动
 *通过针对Spring上下文仅注册{@code-AppConfig}：
 *
 *<pre-class=“code”>
 *新的AnnotationConfigApplicationContext（AppConfig.class）</预>
 *
 *<h3>带有｛@code@Profile｝注释</h3>
 *
 *＜p＞｛@code@Configuration｝类可以用｛@link Profile@Profile｝注释标记为
 *指示仅当给定的一个或多个配置文件<em>处于活动状态</em>时才应处理它们：
 *
 *<pre-class=“code”>
 * &#064;简介（“开发”）
 * &#064;配置
 *公共类EmbeddedDatabaseConfig{
 *
 *     &#064;豆
 *公共数据源DataSource（）{
 *//实例化、配置并返回嵌入的DataSource
 *     }
 * }
 *
 * &#064;简介（“生产”）
 * &#064;配置
 *公共类ProductionDatabaseConfig{
 *
 *     &#064;豆
 *公共数据源DataSource（）{
 *//实例化、配置并返回生产数据源
 *     }
 *}</pre>
 *
 *＜p＞或者，您也可以在｛@code@Bean｝方法级别声明配置文件条件
 *&mdash；例如，对于同一配置类中的备选bean变体：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类ProfileDatabaseConfig{
 *
 *     &#064;Bean（“数据源”）
 *     &#064;简介（“开发”）
 *公共数据源embeddedDatabase（）｛…｝
 *
 *     &#064;Bean（“数据源”）
 *     &#064;简介（“生产”）
 *公共数据源productionDatabase（）｛…｝
 *}</pre>
 *
 *<p>请参阅｛@link Profile@Profile｝和｛@link.org.springframework.core.env.env.env｝
 *有关更多详细信息，请参阅javadocs。
 *
 *＜h3＞使用｛@code@ImportResource｝注释的Spring XML</h3>
 *
 *<p>如上所述，｛@code@Configuration｝类可以声明为常规Spring
 *｛@code＜bean＞｝定义。也可以
 *使用将Spring XML配置文件导入｛@code@configuration｝类
 *｛@link ImportResource@ImportResource｝注释。从导入的Bean定义
 *XML可以被注入&mdash；例如，使用{@code@Inject}注释：
 *
 *<pre-class=“code”>
 * &#064;配置
 * &#064;ImportResource（“classpath：/com/acme/database-config.xml”）
 *公共类AppConfig{
 *
 *     &#064;注入数据源DataSource；//来自XML
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *//注入XML定义的dataSourcebean
 *返回新的MyBean（this.dataSource）；
 *     }
 *}</pre>
 *
 *<h3>带有嵌套的｛@code@Configuration｝类</h3>
 *
 *＜p＞｛@code@Configuration｝类可以嵌套在另一个类中，如下所示：
 *
 *<pre-class=“code”>
 * &#064;配置
 *公共类AppConfig{
 *
 *     &#064;注入数据源DataSource；
 *
 *     &#064;豆
 *公共MyBean MyBean（）{
 *返回新的MyBean（dataSource）；
 *     }
 *
 *     &#064;配置
 *静态类DatabaseConfig{
 *         &#064;豆
 *数据源数据源（）{
 *返回new EmbeddedDatabaseBuilder（）.build（）；
 *         }
 *     }
 *}</pre>
 *
 *＜p＞当引导这样的安排时，只需要注册｛@code AppConfig｝
 *根据应用程序上下文。由于是嵌套的｛@code@Configuration｝
 *类，｛@code DatabaseConfig｝<em>将自动注册</em>。这样可以避免
 *当
 *｛@code AppConfig｝和｛@code-DatabaseConfig｝已隐式清除。
 *
 *＜p＞还请注意，嵌套的｛@code@Configuration｝类可以用于良好的效果
 *使用{@code@Profile}注释为
 *封闭{@code@Configuration}类。
 *
 *<h2>配置延迟初始化</h2>
 *
 *<p>默认情况下，｛@code@Bean｝方法将在容器中被<em>急切地实例化</em>
 *引导时间。为了避免这种情况，｛@code@Configuration｝可以与
 *｛@link Lazy@Lazy｝注释，以指示声明的所有｛@code@Bean｝方法
 *默认情况下，类内的初始化是延迟的。请注意，可以使用{@code@Lazy}
 *对个别{@code@Bean}方法也是如此。
 *
 *＜h2＞测试对｛@code@Configuration｝类的支持</h2>
 *
 *＜p＞｛@code Spring test｝模块中提供的Spring＜em＞TestContext框架</em＞
 *提供了｛@code@ContextConfiguration｝注释，该注释可以接受
 *<em>组件类</em>引用&mdash；通常｛@code@配置｝或
 *｛@code@Component｝类。
 *
 *<pre-class=“code”>
 * &#064;ExtendeWith（SpringExtension.class）
 * &#064;上下文配置（类=｛AppConfig.class，DatabaseConfig.class｝）
 *类MyTests{
 *
 *     &#064;自动连线MyBean MyBean；
 *
 *     &#064;自动连线数据源DataSource；
 *
 *     &#064;测验
 *无效测试（）{
 *//针对myBean的断言。。。
 *     }
 *}</pre>
 *
 *<p>请参阅
 *<a href=“https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#testcontext-framework“>TestContext框架</a>
 *有关详细信息，请参阅文档。
 *
 *＜h2＞使用｛@code@Enable｝注释启用内置的Spring功能</h2>
 *
 *＜p＞Spring功能，如异步方法执行、调度任务执行、，
 *注释驱动的事务管理，甚至Spring MVC都可以启用
 *使用它们各自的“｛@code@Enable｝”从｛@code@Configuration｝类配置
 *注释。看见
 *｛@link org.springframework.scheduling.annotation.EnableAsync@EnableAsync｝，
 *｛@link org.springframework.scheduling.annotation.EnableScheduling@EnableScheduling｝，
 *｛@link org.springframework.transaction.annotation.EnableTransactionManagement@EnableTransactionManagement｝，
 *｛@link org.springframework.context.annotation.EnableAspectJAutoProxy@EnableAspectJAutoProxy｝，
 *和{@link org.springframework.web.servlet.config.annotation.EnableWebMvc@EnableWebMvc}
 *详细信息。
 *
 *<h2>创作｛@code@Configuration｝类时的约束</h2>
 *
 *＜ul＞
 *<li>配置类必须作为类提供（即，不能作为返回的实例提供
 *来自工厂方法），允许通过生成的子类进行运行时增强。
 *＜li＞配置类必须是非最终类（允许在运行时使用子类），
 *除非将{@link#proxyBeanMethods（）proxyBeanMethods}标志设置为{@code false｝
 *在这种情况下，不需要运行时生成的子类。
 *＜li＞配置类必须是非本地的（即不能在方法中声明）。
 *＜li＞任何嵌套的配置类都必须声明为｛@code static｝。
 *＜li＞｛@code@Bean｝方法可能不会创建更多的配置类
 *（任何此类实例都将被视为常规bean，并进行配置
 *注释未被检测到）。
 *</ul>
 *
 *@作者罗德·约翰逊
 *@作者Chris Beams
 *@作者Juergen Hoeller
 *@自3.0起
 *@见憨豆
 *@参见个人资料
 *@请参阅导入
 *@请参阅ImportResource
 *@请参阅组件扫描
 *@见懒惰
 *@请参阅PropertySource
 *@参见AnnotationConfigApplicationContext
 *@请参阅ConfigurationClassPostProcessor
 *@参见org.springframework.core.env.env.Environment
 *@参见org.springframework.test.context.ContextConfiguration
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {

	/**
	 * Explicitly specify the name of the Spring bean definition associated with the
	 * {@code @Configuration} class. If left unspecified (the common case), a bean
	 * name will be automatically generated.
	 * <p>The custom name applies only if the {@code @Configuration} class is picked
	 * up via component scanning or supplied directly to an
	 * {@link AnnotationConfigApplicationContext}. If the {@code @Configuration} class
	 * is registered as a traditional XML bean definition, the name/id of the bean
	 * element will take precedence.
	 * @return the explicit component name, if any (or empty String otherwise)
	 * @see AnnotationBeanNameGenerator
	 */
	/**
	 *显式指定与
	 *｛@code@Configuration｝类。如果未指定（常见情况），则bean
	 *名称将自动生成。
	 *＜p＞只有在｛@code@Configuration｝类被选中时，自定义名称才适用
	 *通过组件扫描向上或直接提供给
	 *｛@link AnnotationConfigApplicationContext｝。如果｛@code@Configuration｝类
	 *注册为传统的XMLbean定义，bean的名称/id
	 *元素将优先。
	 *@返回显式组件名称（如果有）（否则为空String）
	 *@参见AnnotationBeanNameGenerator
	 */
	@AliasFor(annotation = Component.class)
	String value() default "";

	/**
	 * Specify whether {@code @Bean} methods should get proxied in order to enforce
	 * bean lifecycle behavior, e.g. to return shared singleton bean instances even
	 * in case of direct {@code @Bean} method calls in user code. This feature
	 * requires method interception, implemented through a runtime-generated CGLIB
	 * subclass which comes with limitations such as the configuration class and
	 * its methods not being allowed to declare {@code final}.
	 * <p>The default is {@code true}, allowing for 'inter-bean references' via direct
	 * method calls within the configuration class as well as for external calls to
	 * this configuration's {@code @Bean} methods, e.g. from another configuration class.
	 * If this is not needed since each of this particular configuration's {@code @Bean}
	 * methods is self-contained and designed as a plain factory method for container use,
	 * switch this flag to {@code false} in order to avoid CGLIB subclass processing.
	 * <p>Turning off bean method interception effectively processes {@code @Bean}
	 * methods individually like when declared on non-{@code @Configuration} classes,
	 * a.k.a. "@Bean Lite Mode" (see {@link Bean @Bean's javadoc}). It is therefore
	 * behaviorally equivalent to removing the {@code @Configuration} stereotype.
	 * @since 5.2
	 */
	/**
	 *指定是否应代理｛@code@Bean｝方法以强制执行
	 *bean生命周期行为，例如甚至返回共享的单例bean实例
	 *在用户代码中直接调用{@code@Bean}方法的情况下。此功能
	 *需要方法拦截，通过运行时生成的CGLIB实现
	 *带有限制的子类，如配置类和
	 *其方法不允许声明{@code final}。
	 *＜p＞默认值为｛@code true｝，允许通过直接
	 *配置类内的方法调用以及对的外部调用
	 *这个配置的{@code@Bean}方法，例如来自另一个配置类。
	 *如果这是不需要的，因为这个特定配置的{@code@Bean}
	 *方法是自包含的并且被设计为用于容器使用的普通工厂方法，
	 *将此标志切换为{@code false}，以避免CGLIB子类处理。
	 *<p>关闭bean方法拦截有效地处理{@code@bean}
	 *方法单独声明，就像在非{@code@Configuration}类上声明一样，
	 *又名“@Bean Lite模式”（请参阅{@link-Bean@Bean的javadoc}）。因此
	 *在行为上相当于删除{@code@Configuration}构造型。
	 *@自5.2起
	 */
	boolean proxyBeanMethods() default true;

	/**
	 * Specify whether {@code @Bean} methods need to have unique method names,
	 * raising an exception otherwise in order to prevent accidental overloading.
	 * <p>The default is {@code true}, preventing accidental method overloads which
	 * get interpreted as overloaded factory methods for the same bean definition
	 * (as opposed to separate bean definitions with individual conditions etc).
	 * Switch this flag to {@code false} in order to allow for method overloading
	 * according to those semantics, accepting the risk for accidental overlaps.
	 * @since 6.0
	 */
	/**
	 *指定{@code@Bean}方法是否需要具有唯一的方法名称，
	 *否则会引发异常，以防止意外过载。
	 *＜p＞默认值为｛@code true｝，防止意外的方法重载
	 *被解释为相同bean定义的重载工厂方法
	 *（与使用单独条件等单独的bean定义相反）。
	 *将此标志切换为｛@code false｝，以便允许方法重载
	 *根据这些语义，接受意外重叠的风险。
	 *@自6.0起
	 */
	boolean enforceUniqueMethods() default true;

}
